<?php

$cnt = 0;
$obj = $_POST['OBJ'];
foreach ($obj as $ob) {
	if (empty($ob)) {
		$cnt = 1;
	}
}

if ($obj['genCheck'] != $obj['answered']) {
	$cnt = 1;
}

if (!filter_var($obj[email], FILTER_VALIDATE_EMAIL)) {
	$cnt = 1;
}

if ($cnt != 0) {
	echo 0;
} else {
	$ime = $obj['ime'];
	$email = $obj['email'];
	$subject = $obj['sub'];
	$message = "Salje:$ime\n\n\n".$obj['text'];
	$to = 'hello@i1-creative.com';
	$headers = "From: $email" . "\r\n" .
			'Reply-To: ' . $email . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
	if (mail($to, $subject, $message, $headers)) {
		echo 1;
	} else {
		echo 0;
	}
}
?>
